package com.hoperun.product.net;

import org.json.JSONObject;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.hoperun.product.util.LanguageUtil;

import android.os.Handler;

public class RequestServiceImpl {


	/**
	 * 获取新版本
	 *
	 * @param handler
	 * @param requestType
	 */
	public static void getNewVersion(Handler handler, int requestType,String appname) {

		JSONObject inputInfo = new JSONObject();
		try {
			inputInfo.put("appname", appname);
			inputInfo.put("LANGUAGE", LanguageUtil.getLanguageStr());

		} catch (Exception e) {
			// TODO: handle exception
		}
		String methodName = "autoUpdate";

		IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
	}
	/**
	 * 登录请求
	 * 
	 * @param handler
	 * @param account
	 *            员工工号
	 * @param password
	 *            密码
	 */
	public static void login(Handler handler, int requestType, String account, String password) {

		JSONObject inputInfo = new JSONObject();

		try {
			inputInfo.put("YHM", account);
			inputInfo.put("YHKL", password);
			inputInfo.put("LANGUAGE", LanguageUtil.getLanguageStr());
		} catch (Exception e) {
			// TODO: handle exception
		}
		String methodName = "login";

		IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
	}

	
	/**
	 * 页面初始化统计当日匹数与重量
	 * @param handler
	 * @param requestType
	 * @param account
	 * @param password
	 */
	public static void getInitInfo(Handler handler,int requestType, String userBean) {

		JSONObject inputInfo = new JSONObject();

		try {
			JSONObject jsonObject=new JSONObject(userBean);
			inputInfo.put("userBean", jsonObject);
			inputInfo.put("LANGUAGE", LanguageUtil.getLanguageStr());
	
		
		} catch (Exception e) {
			// TODO: handle exception
		}
		String methodName="TickettoinitApp" ;
		
		IServiceImpl.callWebMethod(handler, requestType, inputInfo , methodName);
	}
	
	
	
	/**
	 * 根据托盘号带出数据
	 * 
	 * @param handler
	 * @param requestType
	 * @param trayNo
	 */
	public static void getTrayByTrayNo(Handler handler, int requestType, String userBean,String trayNo) {

		JSONObject inputInfo = new JSONObject();

		try {
			JSONObject jsonObject=new JSONObject(userBean);
			inputInfo.put("userBean", jsonObject);
			inputInfo.put("TRAYNO", trayNo);
			inputInfo.put("LANGUAGE", LanguageUtil.getLanguageStr());

		} catch (Exception e) {
			// TODO: handle exception
		}
		String methodName = "WhtraybytrayNo";

		IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
	}

	/**
	 * 20. 根据‘三联单号’获取托盘信息
	 * 
	 * @param handler
	 * @param requestType
	 * @param clothTktNo
	 */
	public static void getTrayByTktNo(Handler handler, int requestType, String clothTktNo) {

		JSONObject inputInfo = new JSONObject();

		try {
			inputInfo.put("CLOTHTKTNO", clothTktNo);
			inputInfo.put("LANGUAGE", LanguageUtil.getLanguageStr());

		} catch (Exception e) {
			// TODO: handle exception
		}
		String methodName = "WhtraybTRAYNObyNo";

		IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
	}

	/**
	 * 21. 根据‘三联单号’获取合约信息
	 * 
	 * @param handler
	 * @param requestType
	 * @param clothTktNo
	 */
	public static void getContactByTktNo(Handler handler, int requestType, String clothTktNo) {

		JSONObject inputInfo = new JSONObject();

		try {
			inputInfo.put("CLOTHTKTNO", clothTktNo);
			inputInfo.put("LANGUAGE", LanguageUtil.getLanguageStr());

		} catch (Exception e) {
			// TODO: handle exception
		}
		String methodName = "WhtraybContactNobyNo";

		IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
	}

	/**
	 * 22. 校验三联单号
	 * 
	 * @param handler
	 * @param requestType
	 * @param clothTktNo
	 */
	public static void checkClothTktNo(Handler handler, int requestType, String clothTktNo,String trayNo,String trayCount,String HJ) {

		JSONObject inputInfo = new JSONObject();

		try {
			inputInfo.put("CLOTHTKTNO", clothTktNo);
			inputInfo.put("TRAYNO", trayNo);
			inputInfo.put("TRAYCOUNT", trayCount);
			inputInfo.put("HJ", HJ);

			inputInfo.put("LANGUAGE", LanguageUtil.getLanguageStr());

		} catch (Exception e) {
			// TODO: handle exception
		}
		String methodName = "WhtrayCheckClothtktNo";

		IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
	}

	/**
	 * 23. 校验三联单号与托盘中的三联单号品种是否相同
	 * 
	 * @param handler
	 * @param requestType
	 * @param clothTktNo
	 * @param trayNo
	 */
	public static void checkClothTktNoByDetail(Handler handler, int requestType, String clothTktNo, String trayNo) {

		JSONObject inputInfo = new JSONObject();

		try {
			inputInfo.put("CLOTHTKTNO", clothTktNo);
			inputInfo.put("TRAYNO", trayNo);
			inputInfo.put("LANGUAGE", LanguageUtil.getLanguageStr());
		} catch (Exception e) {
			// TODO: handle exception
		}
		String methodName = "WhtrayCheckClothtktNoTrayNo";

		IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
	}

	/**
	 * 新 增一条数据
	 * 
	 * @param handler
	 * @param requestType
	 * @param userBean
	 * @param clothTktNo
	 */
	public static void addCloth(Handler handler, int requestType, String userBean, String clothTktNo, String trayNo,String trayCount, String trayWeight,
			String packageType, String packageWeight) {

		JSONObject inputInfo = new JSONObject();

		try {

			JSONObject jsonObject = new JSONObject(userBean);
			inputInfo.put("userBean", jsonObject);
			
			
			JSONObject jsonData = new JSONObject();
			jsonData.put("CLOTHTKTNO", clothTktNo);
			jsonData.put("TRAYNO", trayNo);
			inputInfo.put("TRAYCOUNT", trayCount);

			jsonData.put("TRAYWEIGHT", trayWeight);
			jsonData.put("PACKAGETYPE", packageType);
			jsonData.put("PACKAGEWEIGHT", packageWeight);
			inputInfo.put("jsonData", jsonData);
			inputInfo.put("LANGUAGE", LanguageUtil.getLanguageStr());
			
			
		} catch (Exception e) {
			
			// TODO: handle exception
		}
		String methodName = "WhtrayinsertByClothtktNo";

		IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
	}
	
	
	
	
	
	
	
	/**
	 * 25.	删除‘三联单号’已扫描记录
	 * @param handler
	 * @param requestType
	 * @param clothTktNo
	 * @param trayNo
	 */
	public static void deleteCloth(Handler handler, int requestType, String userBean, String clothTktNo) {

		JSONObject inputInfo = new JSONObject();

		try {
			
			JSONObject jsonObject = new JSONObject(userBean);
			inputInfo.put("userBean", jsonObject);
			inputInfo.put("CLOTHTKTNO", clothTktNo);
			inputInfo.put("LANGUAGE", LanguageUtil.getLanguageStr());

		} catch (Exception e) {
			// TODO: handle exception
		}
		String methodName = "WhtrayDeleteClothtktNo";

		IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
	}
	
	
	/**
	 * 26.	点击完成
	 * @param handler
	 * @param requestType
	 * @param userBean
	 * @param trayNo
	 */
	public static void finishUpdate(Handler handler, int requestType, String userBean, String trayNo,String trayWeight, 
			String packageType, String packageWeight) {

		JSONObject inputInfo = new JSONObject();

		try {
			
			JSONObject jsonObject = new JSONObject(userBean);
			inputInfo.put("userBean", jsonObject);
			
			JSONObject jsonData = new JSONObject();
			jsonData.put("TRAYNO", trayNo);
			jsonData.put("TRAYWEIGHT", trayWeight);
			jsonData.put("PACKAGETYPE", packageType);
			jsonData.put("PACKAGEWEIGHT", packageWeight);
			inputInfo.put("jsonData", jsonData);
			inputInfo.put("LANGUAGE", LanguageUtil.getLanguageStr());
			

		} catch (Exception e) {
			// TODO: handle exception
		}
		String methodName = "WhtrayupdateByTRAYNO";

		IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
	}
	
	
	/**
	 * 30.	月底盘点(APP)
	 * 
	 * @param handler
	 * @param requestType
	 * @param trayNo
	 */
	public static void insertYearMothByClothtktNo(Handler handler, int requestType, String userBean,String clothTkNo) {

		JSONObject inputInfo = new JSONObject();

		try {
			JSONObject jsonObject=new JSONObject(userBean);
			inputInfo.put("userBean", jsonObject);
			inputInfo.put("CLOTHTKTNO", clothTkNo);
			inputInfo.put("LANGUAGE", LanguageUtil.getLanguageStr());

		} catch (Exception e) {
			// TODO: handle exception
		}
		String methodName = "WhtrayinsertYearMothByClothtktNo";

		IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
	}


	/**
	 * 棉纱入库-库位判断接口
	 * @param handler
	 * @param requestType
	 */
	public static void storehouseJudge(Handler handler, int requestType, String WHLOCNO) {

		JSONObject inputInfo = new JSONObject();

		try {
			inputInfo.put("WHLOCNO", WHLOCNO);
			inputInfo.put("WHLOCTYPE", "0");
			inputInfo.put("LANGUAGE", LanguageUtil.getLanguageStr());
		} catch (Exception e) {
			// TODO: handle exception
		}
		String methodName = "storehouseJudge";

		IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
	}

	/**
	 *	棉纱入库-入库确认接口
	 * @param handler
	 * @param requestType
	 * @param WHLOCNO
	 */

	public static void inboundConfirm(Handler handler, int requestType, String WHLOCNO,String TXM) {

		JSONObject inputInfo = new JSONObject();

		try {
			inputInfo.put("WHLOCNO", WHLOCNO);
			inputInfo.put("TYPE", "0");
			inputInfo.put("TXM",TXM);
		} catch (Exception e) {
			// TODO: handle exception
		}
		String methodName = "inboundConfirm";

		IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
	}


	/**
	 * 棉纱出库-获取库存信息接口
	 * @param handler
	 * @param requestType
	 * @param WHLOCNO
	 * @param TXM
	 */
	public static void getStockData(Handler handler, int requestType, String UNIONCODE) {

		JSONObject inputInfo = new JSONObject();

		try {
			inputInfo.put("UNIONCODE", UNIONCODE);

		} catch (Exception e) {
			// TODO: handle exception
		}
		String methodName = "getStockData";

		IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
	}

	/**
	 * 棉纱出库-出库确认接口
	 * @param handler
	 * @param requestType
	 * @param WHLOCNO
	 * @param TYPE
	 */
	public static void outboundConfirm(Handler handler, int requestType, String WHLOCNO) {

		JSONObject inputInfo = new JSONObject();

		try {
			inputInfo.put("WHLOCNO", WHLOCNO);
			inputInfo.put("TYPE","2");
		} catch (Exception e) {
			// TODO: handle exception
		}
		String methodName = "outboundConfirm";

		IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
	}

	/**
	 * 棉纱回库-获取配送区库位原料信息接口
	 * @param handler
	 * @param requestType
	 * @param WHLOCNO
	 */
	public static void getReturnboundData(Handler handler, int requestType, String WHLOCNO) {

		JSONObject inputInfo = new JSONObject();

		try {
			inputInfo.put("WHLOCNO", WHLOCNO);
		} catch (Exception e) {
			// TODO: handle exception
		}
		String methodName = "getReturnboundData";

		IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
	}

	/**
	 *  棉纱回库-回库确认接口
	 * @param handler
	 * @param requestType
	 * @param WHLOCNO
	 * @param BOXNUM
	 * @param WEIGHT
	 */
	public static void returnboundConfirm(Handler handler, int requestType, String WHLOCNO, String BOXNUM, String WEIGHT) {

		JSONObject inputInfo = new JSONObject();

		try {
			inputInfo.put("WHLOCNO", WHLOCNO);
			inputInfo.put("BOXNUM", BOXNUM);
			inputInfo.put("WEIGHT", WEIGHT);

		} catch (Exception e) {
			// TODO: handle exception
		}
		String methodName = "returnboundConfirm";

		IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
	}

	/**
	 * 库位释放接口
	 * @param handler
	 * @param requestType
	 * @param WHLOCNO
	 */
	public static void unlockWhloc(Handler handler, int requestType, String WHLOCNO) {

		JSONObject inputInfo = new JSONObject();

		try {
			inputInfo.put("WHLOCNO", WHLOCNO);


		} catch (Exception e) {
			// TODO: handle exception
		}
		String methodName = "unlockWhloc";

		IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
	}


	/**
	 * 外加工根据托盘号带出数据
	 *
	 * @param handler
	 * @param requestType
	 * @param trayNo
	 */
	public static void getWjgTrayByTrayNo(Handler handler, int requestType, String userBean,String trayNo) {

		JSONObject inputInfo = new JSONObject();

		try {
			JSONObject jsonObject=new JSONObject(userBean);
			inputInfo.put("userBean", jsonObject);
			inputInfo.put("TRAYNO", trayNo);
			inputInfo.put("LANGUAGE", LanguageUtil.getLanguageStr());

		} catch (Exception e) {
			// TODO: handle exception
		}
		String methodName = "WhtraybytrayNoOem";

		IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
	}

	/**
	 * 22. 外加工校验三联单号
	 *
	 * @param handler
	 * @param requestType
	 * @param clothTktNo
	 */
	public static void checkWjgClothTktNo(Handler handler, int requestType, String clothTktNo,String trayNo,String flag,String hj) {

		JSONObject inputInfo = new JSONObject();

		try {
			inputInfo.put("CLOTHTKTNO", clothTktNo);
			inputInfo.put("FLAG", flag);
			inputInfo.put("HJ", hj);

			inputInfo.put("TRAYNO", trayNo);
			inputInfo.put("LANGUAGE", LanguageUtil.getLanguageStr());

		} catch (Exception e) {
			// TODO: handle exception
		}
		String methodName = "WhtrayCheckClothtktNoOem";

		IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
	}


	/**
	 * 新 增一条数据
	 *
	 * @param handler
	 * @param requestType
	 * @param userBean
	 * @param clothTktNo
	 */
	public static void addWjgCloth(Handler handler, int requestType, String userBean, String clothTktNo, String trayNo,String trayCount, String trayWeight,
								String packageType, String packageWeight) {

		JSONObject inputInfo = new JSONObject();

		try {

			JSONObject jsonObject = new JSONObject(userBean);
			inputInfo.put("userBean", jsonObject);

			JSONObject jsonData = new JSONObject();
			jsonData.put("CLOTHTKTNO", clothTktNo);
			jsonData.put("TRAYNO", trayNo);
			jsonData.put("TRAYWEIGHT", trayWeight);
			jsonData.put("PACKAGETYPE", packageType);
			jsonData.put("PACKAGEWEIGHT", packageWeight);
			inputInfo.put("jsonData", jsonData);

			inputInfo.put("LANGUAGE", LanguageUtil.getLanguageStr());


		} catch (Exception e) {

			// TODO: handle exception
		}
		String methodName = "WhtrayinsertByClothtktNoOem";

		IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
	}

	/**
	 * 	外加工点击完成
	 * @param handler
	 * @param requestType
	 * @param userBean
	 * @param trayNo
	 */
	public static void finishWjgUpdate(Handler handler, int requestType, String userBean, String trayNo,String trayWeight,
									String packageType, String packageWeight) {

		JSONObject inputInfo = new JSONObject();

		try {

			JSONObject jsonObject = new JSONObject(userBean);
			inputInfo.put("userBean", jsonObject);

			JSONObject jsonData = new JSONObject();
			jsonData.put("TRAYNO", trayNo);
			jsonData.put("TRAYWEIGHT", trayWeight);
			jsonData.put("PACKAGETYPE", packageType);
			jsonData.put("PACKAGEWEIGHT", packageWeight);
			inputInfo.put("jsonData", jsonData);

			inputInfo.put("LANGUAGE", LanguageUtil.getLanguageStr());


		} catch (Exception e) {
			// TODO: handle exception
		}
		String methodName = "WhtrayupdateByTRAYNOOem";

		IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
	}
}
